package com.iot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Description: swagger 配置文件
 *
 * @author IceZhang
 * Copyright  2020-2021  棉捷深圳科技有限公司
 * All rights reserved.
 * @version: 1.0
 * Reversion:
 * 1.0 - 新建
 */
@Configuration
@EnableSwagger2
public class Swagger2 {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(this.apiInfo())
                .groupName("全部接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.iot.controller"))
                .paths(PathSelectors.any())
                .build();
                
    }
 
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("物联网关API文档")
                .description("提供设备及上报数据相关接口")
                .contact(new Contact("开发团队", "http://www.bodyta.com", "dev@bodyta.com"))
                .termsOfServiceUrl("http://www.bodyta.com")
                .version("1.0")
                .build();
    }
}